package com.jy.wms.controller;

import com.joyi.gate.comm.SessionInfo;
import com.joyi.gate.safety.vo.UserInfo;
import com.jy.wms.common.base.BaseController;
import com.jy.wms.common.base.BaseSessionInfo;
import com.jy.wms.pojo.SysHz;
import com.jy.wms.pojo.WmsProvinceRankingReport;
import com.jy.wms.service.WmsProvinceRankingReportService;
import com.jy.wms.service.WmsReportHeaderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONObject;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/WmsReportHeaderController")
@Api(value = "/WmsReportHeaderController", description = "报表表头")
public class WmsReportHeaderController extends BaseController<WmsReportHeaderService, WmsProvinceRankingReport> {

    @PostMapping(value = "WmsFreightHead")
    @ApiOperation(value = "运费表头", response = JSONObject.class, notes = "表头")
    public @ResponseBody
    JSONObject WmsFreightHead(@RequestBody Map<String,Object> mapp,HttpSession session) {
        JSONObject json = null;

        //获取当前操作用户的货主id
        List<SysHz> hz=(List<SysHz>)session.getAttribute(BaseSessionInfo.SessionConsignor);
        String hzid= hz.get(0).getHzid();
        //获取仓库Id
        UserInfo userinfo= (UserInfo) session.getAttribute(SessionInfo.USER_INFO);
        String ckid= userinfo.getUser().getOrgId().get(0).toString();

        json=baseService.WmsFreightHead(mapp,hzid,ckid);
        return json;
    }

    @PostMapping(value = "supportnumberhead")
    @ApiOperation(value = "支数表头", response = JSONObject.class, notes = "表头")
    public @ResponseBody
    JSONObject supportnumberhead(@RequestBody  Map<String,Object> mapp,HttpSession session) {
        JSONObject json = null;

        //获取当前操作用户的货主id
        List<SysHz> hz=(List<SysHz>)session.getAttribute(BaseSessionInfo.SessionConsignor);
        String hzid= hz.get(0).getHzid();
        //获取仓库Id
        UserInfo userinfo= (UserInfo) session.getAttribute(SessionInfo.USER_INFO);
        String ckid= userinfo.getUser().getOrgId().get(0).toString();

        json=baseService.supportnumberhead(mapp,hzid,ckid);
        return json;
    }

    @PostMapping(value = "Saleshead")
    @ApiOperation(value = "销售额表头", response = JSONObject.class, notes = "表头")
    public @ResponseBody
    JSONObject Saleshead(@RequestBody String sate,HttpSession session) {
        JSONObject json = null;

        //获取当前操作用户的货主id
        List<SysHz> hz=(List<SysHz>)session.getAttribute(BaseSessionInfo.SessionConsignor);
        String hzid= hz.get(0).getHzid();
        //获取仓库Id
        UserInfo userinfo= (UserInfo) session.getAttribute(SessionInfo.USER_INFO);
        String ckid= userinfo.getUser().getOrgId().get(0).toString();

        json=baseService.Saleshead(sate,hzid,ckid);
        return json;
    }

    @PostMapping(value = "Orderquantityheader")
    @ApiOperation(value = "订单量表头", response = JSONObject.class, notes = "表头")
    public @ResponseBody
    JSONObject Orderquantityheader(@RequestBody String state ,HttpSession session) {
        JSONObject json = null;

        //获取当前操作用户的货主id
        List<SysHz> hz=(List<SysHz>)session.getAttribute(BaseSessionInfo.SessionConsignor);
        String hzid= hz.get(0).getHzid();
        //获取仓库Id
        UserInfo userinfo= (UserInfo) session.getAttribute(SessionInfo.USER_INFO);
        String ckid= userinfo.getUser().getOrgId().get(0).toString();

        json=baseService.Orderquantityheader(state,hzid,ckid);
        return json;
    }
}
